package com.cyf.db.bean;

import lombok.Data;

/**
 * 车场设备
 * Created by hfy on 2017/7/22.
 */
@Data
public class LocalDevice {

    /* 设备类型 */
    public static final String TYPE_MAIN_IN = "主入口";
    public static final String TYPE_MAIN_OUT = "主出口";
    public static final String TYPE_SEC_IN = "次入口";
    public static final String TYPE_SEC_OUT = "次出口";

    public static final int TYPE_MAIN_IN_INT = 1;
    public static final int TYPE_MAIN_OUT_INT = 2;
    public static final int TYPE_SEC_IN_INT = 3;
    public static final int TYPE_SEC_OUT_INT = 4;

    private Integer id;
    private Integer parkingId;
    /**
     * 设备名称
     */
    private String name;
    /**
     * 设备类型
     */
    private String deviceType;
    /**
     * 岗亭id
     */
    private Integer sentryboxId;
    /**
     * 车场设备id
     */
    private Integer localDeviceId;
    /**
     * 相机ip
     */
    private String ipcIp;
    /**
     * 第二个相机ip
     */
    private String ipcIp2;

    /**
     * 设备是否是入口
     *
     * @return
     */
    public boolean isInDevice() {
        switch (this.deviceType) {
            case TYPE_MAIN_IN:
            case TYPE_SEC_IN:
                return true;
            default: {
                return false;
            }
        }
    }

    /**
     * 解析设备类型（字符串转成int）
     *
     * @return int 设备类型
     */
    public Integer parseDeviceType() {
        switch (this.deviceType) {
            case LocalDevice.TYPE_MAIN_IN:
                return TYPE_MAIN_IN_INT;
            case LocalDevice.TYPE_MAIN_OUT:
                return TYPE_MAIN_OUT_INT;
            case LocalDevice.TYPE_SEC_IN:
                return TYPE_SEC_IN_INT;
            case LocalDevice.TYPE_SEC_OUT:
                return TYPE_SEC_OUT_INT;
            default: {
                return TYPE_MAIN_IN_INT;
            }
        }
    }
}
